/* eslint-disable camelcase */
import request from '@/utils/request.js'

export const loginPost = ({ username, password }) => {
  return request.post('/api/login', {
    username,
    password
  })
}

export const regPost = ({ username, password, repassword }) => {
  return request.post('/api/reg', {
    username,
    password,
    repassword
  })
}

export const userInfoGet = () => {
  // return request.get('/my/userinfo', {
  //   headers: {
  //     Authorization: window.localStorage.getItem('token')
  //   }
  // })
  return request.get('/my/userinfo')
}

export const updateUserInfo = ({ id, nickname, email }) => {
  return request.put('/my/userinfo', {
    id,
    nickname,
    email
  })
}

export const reqUpdatePwd = ({ old_pwd, new_pwd, re_pwd }) => {
  return request.patch('/my/updatepwd', {
    old_pwd,
    new_pwd,
    re_pwd
  })
}

export const updateAvatar = avatar => {
  return request.patch('/my/update/avatar', {
    avatar
  })
}
